﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;

namespace UmlDesigner.Model.WorkUnits
{
    class MoveWorkUnit : IWorkUnit
    {
        internal MoveWorkUnit(ItemWidget item, int nx, int ny)
        {
            target = item;
            x = nx;
            y = ny;
        }

        ItemWidget target;
        int x, y;

        #region IWorkUnit Members

        public void Do(UmlDesigner.Gui.UmlControl umlControl)
        {
            MoveAndSwap();
        }

        public void Undo(UmlDesigner.Gui.UmlControl umlControl)
        {
            MoveAndSwap();
        }

        private void MoveAndSwap()
        {
            int tx, ty;
            tx = target.Position.X;
            ty = target.Position.Y;
            target.SetClassPosition(new Point(x, y));
            x = tx;
            y = ty;
        }

        #endregion
    }
}
